#ifndef __SPI_F_H__
#define __SPI_F_H__

//**********************************
//      Extra Data Definition
//**********************************
#define SPI_DONE_F 0
#define SPI_ERROR_F 1


#define PROTECT_UPPER_F  0x84
#define PROTECT_LOWER_F  0x94
#define PROTECT_ALL_F    0x88
#define CANCEL_PROTECT_F 0x80

#endif

#ifdef __SPI_F_C__
#define __SPI_F_EXTERN__
#else 
#define __SPI_F_EXTERN__ extern
#endif

__SPI_F_EXTERN__ void spi_flash_init(void);
__SPI_F_EXTERN__ void spi_flash_tx(unsigned char dat);
__SPI_F_EXTERN__ unsigned char spi_flash_rx(void);
__SPI_F_EXTERN__ void Write_Enable_F(void);
__SPI_F_EXTERN__ void Write_Disable_F(void);
__SPI_F_EXTERN__ unsigned char Read_Status_F(void);
__SPI_F_EXTERN__ void Write_Status_F(unsigned char BUF);
__SPI_F_EXTERN__ void Protect_Upper_Memory_F(void);
__SPI_F_EXTERN__ void Protect_Lower_Memory_F(void);
__SPI_F_EXTERN__ void Protect_All_Memory_F(void);
__SPI_F_EXTERN__ void Cancel_Memory_Protect_F(void);


__SPI_F_EXTERN__ void Erase_F(unsigned char command, unsigned char address_23_16, unsigned int address_15_0);
__SPI_F_EXTERN__ unsigned char Section_Erase_F(unsigned char address_23_16,
                                  unsigned int address_15_0);
__SPI_F_EXTERN__ unsigned char Block_Erase_F(unsigned char address_23_16,
                                  unsigned int address_15_0);


__SPI_F_EXTERN__ unsigned char Page_Program_F(unsigned char address_23_16,
                                 unsigned int address_15_0,
                                 unsigned char const *write_data,
                                 unsigned int counter);
__SPI_F_EXTERN__ void ReadData_F(unsigned char address_23_16,
                             unsigned int address_15_0,
                             unsigned char *read_data,
                             unsigned int counter);
							 
